<!--{eval global $tid, $fid, $discuz_uid, $thisgid, $catlist, $advitems, $postlist, $admode;}-->
<!--{if CURSCRIPT == 'forumdisplay' && $queryfloat}-->
<script type="text/javascript">
	var normalthreads = new Array();
	var floatthreads = new Array();
	var tbodys = $('forum_$fid') ? $('forum_$fid').getElementsByTagName('tbody') : new Array();
	var randtbody = null;
	for(var i in tbodys) {
		if(tbodys[i].id) {
			if(tbodys[i].id.substr(0, 12) == 'normalthread') {
				normalthreads.push(tbodys[i]);
			} else if(tbodys[i].id.substr(0, 11) == 'floatthread') {
				floatthreads.push(tbodys[i]);
			}
		}
	}
	if(normalthreads.length) {
		for(var i = 0; i < floatthreads.length; i++) {
			var randtbody = normalthreads[Math.floor(Math.random()*normalthreads.length)];
			randtbody.insertBefore(floatthreads[i].getElementsByTagName('tr')[0], randtbody.getElementsByTagName('tr')[0]);
			floatthreads[i].parentNode.removeChild(floatthreads[i]);
		}
	}
</script>
<!--{/if}-->
<!--{if !$admode || !empty($insenz['hardadstatus'])}-->
	<div style="display: none" id="hide_ads">
	<div id="hide_ad_headerbanner"><!--{if !empty($advlist['headerbanner'])}-->$advlist[headerbanner]<!--{/if}--></div>
	<!--{if !empty($advlist['text'])}--><div class="ad_text" id="hide_ad_text"><table summary="Text Ad" cellpadding="0" cellspacing="1">$advlist[text]</table></div><!--{/if}-->
	<!--{if CURSCRIPT == 'index' && !empty($advlist['intercat'])}-->
		<!--{loop $catlist $key $cat}-->
			<!--{if $advlist['intercat'][$key] = array_merge(($advlist['intercat'][0] ? $advlist['intercat'][0] : array()), ($advlist['intercat'][$key] ? $advlist['intercat'][$key] : array()))}-->
				<div class="ad_column" id="hide_ad_intercat_$key"><!--{echo $advitems[$advlist['intercat'][$key][array_rand($advlist['intercat'][$key])]]}--></div>
			<!--{/if}-->
		<!--{/loop}-->
	<!--{/if}-->
	<!--{if CURSCRIPT == 'viewthread'}-->
		<!--{if !$thread['special']}-->
		<!--{loop $postlist $post}-->
			<!--{if $post['count'] > 0}-->
				<!--{if !empty($advlist['thread1'][$post['count']])}--><div class="ad_textlink1" id="hide_ad_thread1_$post[count]">$advlist[thread1][$post[count]]</div><!--{/if}-->
				<!--{if !empty($advlist['thread2'][$post['count']])}--><div class="ad_textlink2" id="hide_ad_thread2_$post[count]">$advlist[thread2][$post[count]]</div><!--{/if}-->
				<!--{if !empty($advlist['thread3'][$post['count']])}--><div class="ad_pip" id="hide_ad_thread3_$post[count]">$advlist[thread3][$post[count]]</div><!--{/if}-->
			<!--{else}-->
				<div class="ad_textlink1" id="hide_ad_thread1_0">$advlist[thread1][0]</div>
				<div class="ad_textlink2" id="hide_ad_thread2_0">$advlist[thread2][0]</div>
				<div class="ad_pip" id="hide_ad_thread3_0">$advlist[thread3][0]</div>
			<!--{/if}-->
		<!--{/loop}-->
		<!--{/if}-->
		<div class="ad_column" id="hide_ad_interthread"><!--{if !empty($advlist['interthread']) && $thread['replies']}-->$advlist[interthread]<!--{/if}--></div>
	<!--{/if}-->
	<div class="ad_footerbanner" id="hide_ad_footerbanner1">$advlist[footerbanner1]</div>
	<div class="ad_footerbanner" id="hide_ad_footerbanner2">$advlist[footerbanner2]</div>
	<div class="ad_footerbanner" id="hide_ad_footerbanner3">$advlist[footerbanner3]</div>
	</div>
	<script type="text/javascript">
		function showads(unavailables, filters) {
			var ad, re;
			var hideads = $('hide_ads').getElementsByTagName('div');
			var insenzads = {'headerbanner' : '1', 'thread3_0' : '2', 'thread2_0' : '3', 'thread1_0' : '4', 'interthread' : '5', 'footerbanner1' : '6', 'footerbanner2' : '7', 'footerbanner3' : '8'};
			for(var i = 0; i < hideads.length; i++) {
				if(hideads[i].id.substr(0, 8) == 'hide_ad_' && (ad = $(hideads[i].id.substr(5))) && hideads[i].innerHTML && trim(ad.innerHTML) == '') {
					if(unavailables) {
						re = new RegExp(insenzads[hideads[i].id.substr(8)] + "\:(0" + "|" + gid + "|" + fid + ")", "ig");
						if(re.exec(unavailables) != null) continue;
					} else if(filters) {
						if(in_array(insenzads[hideads[i].id.substr(8)], filters)) continue;
					}
					ad.innerHTML = hideads[i].innerHTML;
					ad.className = hideads[i].className;
				}
			}
		}
	</script>
	<!--{if !empty($insenz['hardadstatus'])}-->
		<!--{if !empty($insenz['hash'])}-->
			<script type="text/javascript">
				var insenz_cached = true;
				showads();
			</script>
			<!--{if !empty($advlist['insenz'])}-->$advlist['insenz']<!--{/if}-->
			<script type="text/javascript" src='$insenz[jsurl]&gid=$thisgid&fid=$fid&tid=$tid&uid=$discuz_uid&random={echo random(4)}' charset="UTF-8"></script>
		<!--{else}-->
			<script type="text/javascript">
				var insenz_cached = false;
				var insenz_cookie = getcookie('insenz_cookie');
				if(insenz_cookie) {
					showads(insenz_cookie);
				}
			</script>
			<script type="text/javascript" src='$insenz[jsurl]&gid=$thisgid&fid=$fid&tid=$tid&uid=$discuz_uid&random={echo random(4)}' charset="UTF-8"></script>
			<script type="text/javascript">
				if(typeof insenz_usedadkeys == 'object' && typeof insenz_advs == 'object' && insenz_usedadkeys.length && insenz_advs.length) {
					insenz_cookie = '';
					for(var j in insenz_advs) {
						for(var k in insenz_advs[j]) {
							insenz_cookie += j + ':' + k + 'D';
						}
					}
					setcookie('insenz_cookie', insenz_cookie, 86400);
				} else {
					insenz_cookie = 1;
					setcookie('insenz_cookie', '', -86400);
					var insenz_usedadkeys = new Array();
				}
				showads('', insenz_usedadkeys);
			</script>
		<!--{/if}-->
		<script type="text/javascript">
			if(typeof insenz_hash != 'undefined' && insenz_hash != '$insenz[hash]') {
				document.write('<scr'+'ipt type="text/javas'+'cript" src="api/advcache.php"></'+'script>');
			}
		</script>
	<!--{else}-->
		<script type="text/javascript">showads();</script>
	<!--{/if}-->
	<script type="text/javascript">$('hide_ads').parentNode.removeChild($('hide_ads'));</script>
<!--{/if}-->
<!--{if CURSCRIPT == 'viewthread' && $insenz['topicrelatedad'] && !$thread['special']}-->
	<script type="text/javascript">var tradekeywords = '$GLOBALS[tradekeywords]';</script>
	<!--{echo stripslashes($insenz['topicrelatedad'])}-->
<!--{/if}-->
<!--{if !empty($advlist['float']) || !empty($advlist['couplebanner'])}-->
	<div align="left"  style="clear: both;">
	<script type="text/javascript" src="include/js/floatadv.js?{VERHASH}"></script>
	<script type="text/javascript">
		$advlist[float]
		$advlist[couplebanner]
		theFloaters.play();
	</script>
	</div>
<!--{/if}-->